package de.tum.in.eist.im.shared;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Represents a User in EIST_IM environment. A User has a username and a
 * password. Two users are considered equal, if their both username and
 * passwords are equal.
 * 
 * @author zardosht
 * 
 */
public class User implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public int hashCode() {
		String temp = username + password;
		return temp.hashCode();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof User)) {
			return false;
		}
		User other = (User) obj;
		return this.username.equals(other.username)
				&& this.password.equals(other.password);
	}

	private String username;
	private String password;
	private List<String> userGroupList;

	public User() {

	}

	public User(String username, String password) {
		this.username = username;
		this.password = password;
		userGroupList = new ArrayList<String>();
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}

	public List<String> getUserGroupList() {
		return userGroupList;
	}

	public void addGroupStringList(String newGroupName) {
		userGroupList.add(newGroupName);
	}

	public void removeFromGroup(String oldGroupName) {
		userGroupList.remove(oldGroupName);
	}

}
